#include <burst_kernel.h>

/* bus_event_sleep: 
 *
 * To sleep a event.It is not really sleeping it is just skip it
 * when it is a sleeping event;
 */
void bus_event_sleep(bus_event_t *ev)
{
	ev->status |= BUS_IO_SLEEPING;
}

/* bus_event_wake: 
 * 	To wake up a event.It can wake up an event and the finite state machine
 * 	will start processing the IO request on this event.
 */
void bus_event_wake(bus_event_t *ev)
{
	ev->status &= (~BUS_IO_SLEEPING);
}


/* bus_event_io_open: 
 * 
 * To open the IO gate of the event.
 * When the gate is opened the finite state machine will try to finish the IO 
 * indicate by flag.
 */
void bus_event_io_open(bus_event_t *ev, int flag)
{
	ev->status |= flag;
}

/* bus_event_io_open: 
 * 
 * To close the IO gate of the event.
 * When the gate is close the finite state machine will NOT try to finish the IO 
 * indicate by flag.
 */
void bus_event_io_close(bus_event_t *ev, int flag)
{
	ev->status &= (~flag);
}

/* bus_event_io_status: 
 * 
 * To find out the current gate opened.
 */
int bus_event_io_status(bus_event_t *ev, int flag)
{
	return ev->status & flag;
}


/* Burst event available */

int bus_event_bit(bus_event_t *ev, int flag)
{
	return ev->event & flag;
}

void bus_event_set(bus_event_t *ev, int flag)
{
	ev->event |= flag;
}

void bus_event_unset(bus_event_t *ev, int flag)
{
	ev->event &= (~flag);
}